package com.shangxia.order.service.impl;

import com.shangxia.order.dto.DB_User;
import com.shangxia.order.mapper.OrderMapper;
import com.shangxia.order.po.DB_Order;
import com.shangxia.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author zhouya38158
 * @Package com.example.user.service.impl
 * @date 2021/11/2 14:46
 */
@Service("userService")
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private RestTemplate restTemplate;

    @Override
    public DB_Order queryById(Long id) {
        DB_Order order = orderMapper.selectById(id);
        String url = "http://userserver/user/"+order.getUserId();
        DB_User user = restTemplate.getForObject(url, DB_User.class);
        order.setUser(user);
        return order;
    }
}
